﻿<phone:PhoneApplicationPage 
    x:Class="Wulong.Phone.Dianping.Views.MerchantPivotView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"    
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"  Orientation="Portrait"
    shell:SystemTray.IsVisible="True"
    Style="{StaticResource TransitionPageStyle}"
    >

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot">
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="/Images/PageBackground.png"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid.Resources>
            <Style x:Key="ReviewListBoxStyle" TargetType="ListBox">
                <Setter Property="Background" Value="Transparent"/>
                <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}"/>
                <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
                <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
                <Setter Property="BorderThickness" Value="0"/>
                <Setter Property="BorderBrush" Value="Transparent"/>
                <Setter Property="Padding" Value="0"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="ListBox">
                            <ScrollViewer x:Name="ScrollViewer" 
                                      BorderBrush="{TemplateBinding BorderBrush}" 
                                      BorderThickness="{TemplateBinding BorderThickness}" 
                                      Background="{TemplateBinding Background}" 
                                      Foreground="{TemplateBinding Foreground}" 
                                      Padding="{TemplateBinding Padding}">
                                <StackPanel>
                                    <ItemsPresenter/>
                                    <Button cal:Message.Attach="[Event Click]=[Action LoadMore()]" 
                                        Content="{Binding Path=Appi18n.LoadMore, Source={StaticResource ls}}" 
                                        BorderBrush="Transparent" 
                                        BorderThickness="0" 
                                        Visibility="{Binding CanLoadMore, Converter={StaticResource BooleanToVisibilityConverter}}" />
                                </StackPanel>
                            </ScrollViewer>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Grid.Resources>
        <adduplex:AdControl xmlns:adduplex="clr-namespace:AdDuplex;assembly=AdDuplex.AdControl.Silverlight"
                            Grid.Row="0" 
                            AppId="4135" 
                            Background="Transparent"
                            BackgroundOpacity="0.5"
                            />
        <controls:Pivot
            Grid.Row="1"
            Title="{Binding Path=Appi18n.App_Title, Source={StaticResource ls}}">
            <!--Pivot item one-->
            <controls:PivotItem 
                Header="{Binding Path=Appi18n.Merchant_Intro, Source={StaticResource ls}}">
                <ScrollViewer>
                    <StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding ImageUrl}"
                                   Margin="0,12"
                                   Width="120"/>
                            <StackPanel>
                                <TextBlock 
                                    Style="{StaticResource PhoneTextLargeStyle}"
                                    Foreground="Brown"
                                    Text="{Binding Merchant.Name}"/>
                                <TextBlock 
                                    Style="{StaticResource PhoneTextNormalStyle}"
                                    Foreground="SaddleBrown"
                                    Text="{Binding Merchant.AvgPrice}"/>
                                <TextBlock 
                                    Foreground="SaddleBrown"
                                    Style="{StaticResource PhoneTextNormalStyle}"
                                    Text="{Binding Merchant.DetailRating}"/>
                            </StackPanel>
                        </StackPanel>
                        <TextBlock 
                            Style="{StaticResource PhoneTextLargeStyle}"
                            Foreground="#4f391e"
                            Text="{Binding Source={StaticResource ls}, Path=Appi18n.Recommend}"/>
                        <TextBlock 
                            Style="{StaticResource PhoneTextNormalStyle}"
                            Text="{Binding Merchant.Desc}"
                            TextWrapping="Wrap"/>
                        <StackPanel Orientation="Horizontal" >
                            <Image 
                                Source="/Images/Addr.png"
                                Width="64"
                                Margin="12,0"
                                HorizontalAlignment="Left"/>
                            <TextBlock 
                                TextWrapping="Wrap"
                                Style="{StaticResource PhoneTextNormalStyle}"
                                Text="{Binding Merchant.Addr}"
                                VerticalAlignment="Center"
                                Width="350"
                                />
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Image 
                                Source="/Images/Tel.png"
                                Width="64"
                                Margin="12,0"/>
                            <HyperlinkButton 
                                x:Name="MakePhoneCall"
                                Content="{Binding Merchant.Tel}"
                                HorizontalAlignment="Left"/>
                        </StackPanel>
                        <Image
                            Margin="12,0"
                            Source="{Binding MapUrl}"/>
                    </StackPanel>
                </ScrollViewer>
            </controls:PivotItem>
            <controls:PivotItem
                Header="{Binding Path=Appi18n.Merchant_Reviews, Source={StaticResource ls}}">
                <ListBox
                    x:Name="ReadReview" 
                    HorizontalAlignment="Left" 
                    SelectedItem="{Binding SelectedReview, Mode=TwoWay}"
                    ItemsSource="{Binding Reviews}"
                    Style="{StaticResource ReviewListBoxStyle}"
                    >
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Vertical" Margin="12,10,10,12">
                                <StackPanel Orientation="Horizontal" Margin="5,5,5,5">
                                    <TextBlock 
                                        Text="{Binding Author}"
                                        TextWrapping="Wrap"
                                        Width="100"
                                        Foreground="Crimson"
                                        Style="{StaticResource PhoneTextSmallStyle}"
                                        />
                                    <TextBlock 
                                        Text="{Binding PublishDate}"
                                        Foreground="DarkCyan"
                                        Style="{StaticResource PhoneTextSmallStyle}"/>
                                </StackPanel>
                                <TextBlock 
                                    Text="{Binding BriefReview}"
                                    TextWrapping="Wrap"
                                    Width="380"
                                    Style="{StaticResource PhoneTextNormalStyle}"
                                    Foreground="Black"/>
                                <toolkit:Separator 
                                    BorderBrush="PeachPuff" 
                                    BorderThickness="1" 
                                    Width="440" />
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </controls:PivotItem>
        </controls:Pivot>
    </Grid>
    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator 
            IsIndeterminate="{Binding IsBusy}" 
            IsVisible="{Binding IsBusy}"
            Text="{Binding Path=Appi18n.Loading, Source={StaticResource ls}}"/>
    </shell:SystemTray.ProgressIndicator>
</phone:PhoneApplicationPage>